package com.vidyu.datalayer.dataaccesscomponents.impl;

import com.vidyu.businesslayer.businessentities.Project;
import com.vidyu.datalayer.dataaccesscomponents.ProjectDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by IntelliJ IDEA.
 * User: eyalsa
 * Date: 28/02/12
 * Time: 14:38
 * Implementation Dao object for ContractorDao
 */

@SuppressWarnings({"unchecked", "UnusedDeclaration"})
@Repository("projectDao")
public class ProjectDaoImpl extends BaseDaoImpl implements ProjectDao {

    @Autowired
    private HibernateTemplate template;

    @Override
    @Transactional(readOnly = false, propagation = Propagation.NESTED)
    public long save(Project project){
        return ((Long) template.save(project));
    }


    @Override
    @Transactional(readOnly = false, propagation = Propagation.NESTED)
    public void update(Project project){
        template.update(project);
    }

    @Override
    public Project findById(long id) {
        return template.get(Project.class, id);
    }


}
